package com.jialiang;

import java.io.File;
import java.io.IOException;

import static jdk.nashorn.internal.objects.NativeString.substring;

public class FolderCreator {
    public static void main(String[] args) {
        String[] firstLevelFolders = {"4-1", "4-2", "7-4"};
        String[] secondLevelFolders = {"A", "B", "C", "D"};
        String[] thirdLevelFolders = {"01F", "02F", "03F", "04F", "05F", "06F", "07F", "08F", "屋面层"};
        String[] fourthLevelFolders = {"1", "2"};
        String[] num = new String[]{
                "ALE-%s_%sJ1_F%s",
                "AL-%s_%sJ1_F%s",
                "AL-%s_%sJ1_F%s-CZ ",
                "AL-%s_%sJ1_F%s-ZM ",
                "ALZ-%s_%sJ1_F%s"
        };

        // 循环遍历第一层文件夹  
        for (String firstLevelFolder : firstLevelFolders) {
            // 创建第一层文件夹  
            File folder1 = new File(firstLevelFolder);
            if (!folder1.exists()) {
                folder1.mkdir();
            }

            // 循环遍历第二层文件夹  
            for (String secondLevelFolder : secondLevelFolders) {
                // 创建第二层文件夹  
                File folder2 = new File(folder1, firstLevelFolder + "-" + secondLevelFolder);
                if (!folder2.exists()) {
                    folder2.mkdir();
                }

                // 循环遍历第三层文件夹  
                for (String thirdLevelFolder : thirdLevelFolders) {
                    // 创建第三层文件夹  
                    File folder3 = new File(folder2, firstLevelFolder + "-" + secondLevelFolder + "-" + thirdLevelFolder);
                    if (!folder3.exists()) {
                        folder3.mkdir();
                    }
                    for (String s : num) {
                        String t = "";
                        switch (firstLevelFolder){
                            case "4-1":
                                t="T1";
                                break;
                            case "4-2":
                                t="T2";
                                break;
                            case "7-4":
                                t="T3";
                                break;
                        }


                        File file = new File(folder3,String.format(s,
                                t,secondLevelFolder,thirdLevelFolder.substring(0, 2)
                                ));
                        if (thirdLevelFolder.equals("屋面层")){
                            continue;
                        }
                        file.mkdir();
                    }
                    // 循环遍历第四层文件夹
                    for (String fourthLevelFolder : fourthLevelFolders) {
                        // 创建第四层文件夹
                        File folder4 = new File(folder3, firstLevelFolder + "-" + secondLevelFolder + "-" + thirdLevelFolder + "-" + fourthLevelFolder);
                        if (folder2.toString().endsWith("7-4-A") || folder2.toString().endsWith("7-4-B")) {
                            System.out.println();
                            if (!folder4.exists()) {
                                folder4.mkdir();
                            }
                        }

                    }

                }
            }
        }

        System.out.println("文件夹创建完成！");
    }
}